package com.maple.common.widget.dialog

import android.content.Context
import android.os.Bundle
import android.view.View
import android.widget.ImageButton
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.blankj.utilcode.util.ScreenUtils
import com.maple.base.widget.dialog.BaseDialogFragment
import com.maple.common.R
import com.maple.common.ui.adapter.DeviceAdapter

class DeviceDialog(context: Context,val listAdapter: DeviceAdapter): BaseDialogFragment(context, mWidth = (ScreenUtils.getScreenWidth() * 0.48).toInt()) {

    private var tvTitle: TextView? = null
    private var ibtnClose: ImageButton? = null
    private var rvList: RecyclerView? = null
    override fun getLayoutId(): Int = R.layout.dialog_device

    override fun initFragment(view: View, savedInstanceState: Bundle?) {
        tvTitle = view.findViewById(R.id.tv_title)
        tvTitle?.text = "选择设备"
        ibtnClose = view.findViewById(R.id.ibtn_close)
        ibtnClose?.setOnClickListener {
            dismiss()
        }
        rvList = view.findViewById(R.id.rv_list)
        rvList?.let {
            it.layoutManager = LinearLayoutManager(context)
            it.adapter = listAdapter
        }
    }
}